<table class = "leftmenu" border="0">
	<tr valign="top">
		<td width="1">
			<?php
				//generated code menu
				if (!empty($this->data['generated_code_menu']))
				{
					echo TreeMenu::CreateMenu($this->data[generated_code_menu]);
					echo "<br /><hr /><br />";
				}
			
				//code generator menu
				if (!empty($this->data[code_generator_menu]))
				{
					echo TreeMenu::CreateMenu($this->data[code_generator_menu]);
					echo "<br /><hr /><br />";	
				}
				
				$flag = 0;
				if (empty($_SESSION[main_menu]))
				{
					//main menu array
					$main_menu = array
					(
						'root' => array
						(
							'name' => ucfirst(LANG_PROJECT_EXPLORER),
							'url' => null,
							'sub' => array
							(
								'new' => array
								(
									'name' => LANG_NEW_PAGE,
									'url' => '/spanel/codegenerator/choosetable/',
								),
								'config' => array
								(
									'name' => LANG_CONFIGURATION_FILE,
									'url' => '/spanel/appconfig',
								)
							)
						)
					);
									
					//languages
					$main_menu[root]['sub'][languages]['name'] = LANG_LANGUAGES;
					$main_menu[root]['sub'][languages]['url'] = null;
					foreach ($this->GetFileNames("././app/includes/languages/") as $language)
					{
						$main_menu['root']['sub']['languages']['sub'][$language]['name'] = $language;
						$main_menu['root']['sub']['languages']['sub'][$language]['url'] = "/spanel/languages/edit/$language";
						
						$lang_folders = scandir("././app/includes/languages/$language");
						
						foreach ($lang_folders as $lang_folder)
						{
							if (is_dir("././app/includes/languages/$language/$lang_folder") && ($lang_folder != 'CVS') && ($lang_folder != '.svn') && ($lang_folder != '.') && ($lang_folder != '..'))
							{
								$main_menu['root']['sub']['languages']['sub'][$language]['sub'][$lang_folder]['name'] = $lang_folder;
								$main_menu['root']['sub']['languages']['sub'][$language]['sub'][$lang_folder]['url'] = null;
								
								foreach ($this->GetFileNames("././app/includes/languages/$language/$lang_folder") as $lang_file)
								{
									$main_menu['root']['sub']['languages']['sub'][$language]['sub'][$lang_folder]['sub'][$lang_file]['name'] = $lang_file;
									$main_menu['root']['sub']['languages']['sub'][$language]['sub'][$lang_folder]['sub'][$lang_file]['url'] = "/spanel/viewsource/index/?path_to_file=./app/includes/languages/$language/$lang_folder/$lang_file";
								}
							}
							else if ($lang_folder == 'text.php')
							{
								$main_menu['root']['sub']['languages']['sub'][$language]['sub'][$lang_folder]['name'] = 'text';
								$main_menu['root']['sub']['languages']['sub'][$language]['sub'][$lang_folder]['url'] = "/spanel/languages/edit/$language";
							}
						}
					}
					
					//pages
					$main_menu['root']['sub']['pages']['name'] = LANG_PAGES;
					$main_menu['root']['sub']['pages']['url'] = null;
					foreach ($this->GetFileNames("././app/controllers/") as $controller)
					{
						$controller = str_replace('.php', '', $controller);
						$main_menu['root']['sub']['pages']['sub'][$controller]['name'] = $controller;
						$main_menu['root']['sub']['pages']['sub'][$controller]['url'] = null;
						$main_menu['root']['sub']['pages']['sub'][$controller]['sub']['controller']['name'] = LANG_CONTROLLER;
						$main_menu['root']['sub']['pages']['sub'][$controller]['sub']['controller']['url'] = "/spanel/viewsource/index/controller/$controller";
						$main_menu['root']['sub']['pages']['sub'][$controller]['sub']['model']['name'] = LANG_MODEL;
						$main_menu['root']['sub']['pages']['sub'][$controller]['sub']['model']['url'] = "/spanel/viewsource/index/model/$controller";
						//$main_menu['root']['sub']['pages']['sub'][$controller]['sub']['model']['url'] = '\" onMouseOver = "" onClick = "SaveProjectExplorer(document.getElementById(\\\'main_menu_div\\\').innerHTML, this); return false;" onkeyup=\" ';
						$main_menu['root']['sub']['pages']['sub'][$controller]['sub']['views']['name'] = LANG_VIEWS;
						$main_menu['root']['sub']['pages']['sub'][$controller]['sub']['views']['url'] = "";
						
						//gets views' list
						$views = $this->GetFileNames("././app/views/$controller/");
						if ($views)
						{
							foreach ($views as $view)
							{
								$main_menu['root']['sub']['pages']['sub'][$controller]['sub']['views']['sub'][$view]['name'] = $view;
								$main_menu['root']['sub']['pages']['sub'][$controller]['sub']['views']['sub'][$view]['url'] = "/spanel/viewsource/index/view/$controller/$view";	
							}
						}					
					}
					
					//themes
					$main_menu['root']['sub'][themes]['name'] = ucfirst(LANG_THEMES);
					$main_menu['root']['sub'][themes]['url'] = null;
					
					$themes = scandir("./app/themes/");
					foreach ($themes as $theme)
					{
						$theme_name = File::RemoveFileExtention($theme);
						if (($theme_name != 'CVS') && ($theme_name != '.') && ($theme_name != ''))
						{
							$main_menu['root']['sub']['themes']['sub'][$theme]['name'] = $theme;
							$main_menu['root']['sub']['themes']['sub'][$theme]['url'] = null;
							$css_files = scandir("./app/themes/$theme/");
							foreach ($css_files as $css)
							{
								if (pathinfo($css, PATHINFO_EXTENSION) == 'css')
								{
									$main_menu['root']['sub']['themes']['sub'][$theme]['sub'][$css]['name'] = $css;
									$main_menu['root']['sub']['themes']['sub'][$theme]['sub'][$css]['url'] = "/spanel/viewsource/index/?path_to_file=./app/themes/$theme/$css";
								}
							}
						}
					}
					
					//main menu generation
					$_SESSION[main_menu] = TreeMenu::CreateMenu($main_menu, array('leaf' => 'php_file.jpg'));
				}
				else
				{
					$flag = 1;
				}
				echo '<div id = "main_menu_div">'.$_SESSION[main_menu].'</div>';
				
				//if ($flag == 1) echo "<script>document.getElementById('i_div0_0').innerHTML = '';</script>";
				
				//creates file explorer menu
				$this->CreateFileExplorerMenu();
			?>
		</td>
	</tr>
	<tr>
		<td style = 'vertical-align: top'>
			<?php
				if (isset($this->data['path_to_file']))
				{
					echo "<hr />";
					$currentFunctions = File::GetFunctionsListFromFile($this->data['path_to_file']);
					SpherusFileEditor::FileFunctionsListBlock($currentFunctions);
					echo "<br />";
				}
				SpherusFileEditor::FunctionDescriptionBlock("style = 'display: none; table-layout:fixed; width: 250px; border-collapse: collapse; border: 1px solid gray; padding: 0px;'", "style = 'background-color: #999999'", "style = 'vertical-align: top; padding-right: 5px;'");
			?>
		</td>
	</tr>
</table>